{ Statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=744
  Verdict: Accepted
}
uses
	SysUtils, Math;
 
const
	p = 1000547;
	x = 259;
 
var
	j,h,tt:longint;
	s:string;
	f:boolean;
	a:array[0..p] of array of string;
	ch:char;
 
function hash(s:string):int64;
 
var 
	i:longint; 
	c:int64;
 
begin
result:=0;
c:=1;
for i:=1 to length(s) do begin
    c:=(c*x) mod p;
    inc(result,(ord(s[i])*c) mod p);
    result:=result mod p;
end;
end;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
while not eof do begin
	readln(S);
	if s[1] = '#' then halt(0);
	ch:=s[1];
	delete(s,1,2);
	h:=hash(s);
	tt:=length(a[h]) - 1;
	f:=true;
	for j:=0 to tt do
		if a[h][j] = s then begin
			f:=false;
			break;
		end;
	if ch = '+' then begin
		if f then begin
			setlength(a[h],tt+2);
			a[h][tt + 1]:=s;
		end;
	end else begin
		if not f then writeln('YES') else writeln('NO');
	end;
end;
end.